package com.example.exerciseextract2;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.exerciseextract2.adapter.RvAdapter;
import com.example.exerciseextract2.base.BaseActivity;
import com.example.exerciseextract2.bean.RvBean;
import com.example.exerciseextract2.presenter.MainPresenter;
import com.example.exerciseextract2.view.MainView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity<MainPresenter> implements MainView {

    private RecyclerView rv;
    private ArrayList<RvBean.DataBean.DatasBean> list;
    private RvAdapter rvAdapter;


    @Override
    protected void initView() {
        rv = findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(this));
        list = new ArrayList<>();
        rvAdapter = new RvAdapter(getApplicationContext(), list);
        rv.setAdapter(rvAdapter);
    }

    @Override
    protected void initData() {
        mPresenter.getData();
    }

   /* mRv = (RecyclerView) findViewById(R.id.rv);
        mRv.setLayoutManager(new LinearLayoutManager(this));
        mRv.setAdapter(rvAdapter);*/
    @Override
    protected MainPresenter initPresenter() {
        return new MainPresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void setDataa(RvBean bean) {

        rvAdapter.addData(bean.getData().getDatas());
        
    }
}
